﻿<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="../lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/style.css" />
    <title>路由文件和服务之间的关系</title>
</head>

<body>

    <div class="page-container">
        <div class="cl pd-5 bg-1 bk-gray mt-20">

            <!-- <input type="button" class="btnstyle btnadd" value="新增" onclick="_showedit('新增单项','view.html','0','80%','80%');" /> -->
            <input type="text" class="inputword" title="关键字搜索" placeholder="关键字搜索" value=""> <input type="button"
                class="btnsearch" onclick="_readpagedata(1);" value="查询">

            <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
                href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>

        </div>
        <div class="mt-20">
            <table class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
                <thead>
                    <tr class="text-c">
                        <th width="60">ID</th>
                        <th width="60">ServiceID</th>
                        <th >服务名称</th>
                        <th width="60">服务状态</th>
                        <th width="60">NginxId</th>
                        <th >路由文件</th>
                        <th width="60">路由状态</th>                       
                        <th width="150">创建时间</th>
                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
        </div>
        <div id="pagenumarea" class="pagenumarea"></div>
    </div>

    <!--_footer 作为公共模版分离出去-->
    <script type="text/javascript" src="../lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="../lib/layer/2.4/layer.js"></script>
    <script type="text/javascript" src="../static/h-ui/js/H-ui.min.js"></script>
    <script type="text/javascript" src="../lib/jquery.contextmenu/jquery.contextmenu.r2.js"></script>
    <script type="text/javascript" src="../static/h-ui.admin/js/H-ui.admin.js"></script>
    <!--/_footer 作为公共模版分离出去-->
    <!--请在下方写此页面业务相关的脚本-->
    <!-- <script type="text/javascript" src="../lib/My97DatePicker/4.8/WdatePicker.js"></script> -->


    <script src="../lib/api.js"></script>
    <link href="../lib/page.min.css" rel="stylesheet" />
    <script src="../lib/page.min.js"></script>

    <script>
        var pageobject = null;
        $(window).ready(function () {

            pageobject = new Page({
                el: '#pagenumarea',
                nums: 20,//总数
                counts: 30,//每页大小
                defaultPage: 1,
                showHeadFoot: false, // 显示首页尾页
                head: '首', // 更改首页文字
                foot: '尾', // 更改尾页文字
                jumpToOrder: true, // 跳转到指定页
                showNowAndAll: true, // 当前页/共几页
                prev: "上一页",
                next: "下一页",
                clickEvent: function (currectPage, _this) {
                    _readpagedata(currectPage);
                }
            });
            _readpagedata(1);

            $(".inputword").keyup(function (event) {
                if (event.keyCode == 13) {
                    _readpagedata(1);
                }
            });

            // $(".table").on("change", "[type=checkbox]", function (e) {
            //     var checkval = $(this).prop("checked");
            //     var _that = $(this);
            //     var dataid = $(this).attr("dataid");

            //     layer.confirm('确定修改状态么？Enter', {
            //         btn: ["确定", "取消"], success: function () {
            //             this.enterEsc = function (event) {
            //                 if (event.keyCode === 13) {
            //                     $(".layui-layer-btn0").click();
            //                     return false; //阻止系统默认回车事件
            //                 } else if (event.keyCode == 27) {
            //                     $(".layui-layer-btn1").click();
            //                     return false;
            //                 }
            //             };
            //             $(document).on('keydown', this.enterEsc); //监听键盘事件，关闭层
            //         },
            //         end: function () {
            //             $(document).off('keydown', this.enterEsc); //解除键盘关闭事件
            //         }
            //     }, function (index) {
            //         _apiget("/api/spider/jobConfig/" + dataid + "/updateState?state=" + checkval, true, function (code, obj) {
            //             layer.close(index);
            //             if (code != 200) {
            //                 _that.prop("checked", !checkval);
            //             }

            //         });
            //     }, function () {
            //         _that.prop("checked", !checkval);
            //     });


            // })
        });

        function _readpagedata(page) {
            var inputword = $(".inputword").val();

            _apiget("/api/spider/bindNginxService?page=" + page + "&size=" + pageobject.counts + "&word=" + inputword, true, function (code, obj) {
                if (code == 200) {
                    var datas = obj.items;
                    _showpagedata(datas);
                    pageobject.nums = obj.totalCount;
                    var intid = parseInt(pageobject.nums / pageobject.counts); var less = parseInt(pageobject.nums % pageobject.counts); if (less > 0) { pageobject.pages = intid + 1; } else { pageobject.pages = intid; };
                }
            });
        }
        // <th width="60">ID</th>
        //                 <th width="60">ServiceID</th>
        //                 <th >服务名称</th>
        //                 <th width="60">服务状态</th>
        //                 <th width="60">NginxId</th>
        //                 <th >路由文件</th>
        //                 <th width="60">路由状态</th>                       
        //                 <th width="150">创建时间</th>
        function _showpagedata(datas) {

            $("table").find("tbody").empty();
            var hstr = "";
            for (var k = 0; k < datas.length; k++) {
                var item = datas[k];
                var htmlStr = '<tr class="text-c">';
                htmlStr += '<td>' + item.id + '</td>';
                htmlStr += '<td>' + item.servicePoint.id + '</td>';
                htmlStr += '<td>' + item.servicePoint.serviceName + '</td>';
                htmlStr += '<td>' + item.servicePoint.isEnable + '</td>';
                htmlStr += '<td>' + item.nginxPoint.id+'</td>';
                htmlStr += '<td>' + item.nginxPoint.fileName + '</td>';
                htmlStr += '<td>' + item.nginxPoint.isEnable + '</td>';
                htmlStr += '<td>' + item.createDate + '</td>';
                htmlStr += '</tr>';
                hstr += htmlStr;
            }
            $("table").find("tbody").append(hstr);
        }


    </script>


</body>

</html>